package com.laikan.library.httpvolley.request;

import com.android.volley.Request;
import com.android.volley.Response.ErrorListener;
import com.android.volley.Response.Listener;
import com.laikan.library.httpvolley.engine.Requester;
import com.laikan.library.utils.AndroidUtils;
import com.socks.library.KLog;

import java.util.Map;

/**
 * get 请求
 *
 * @author anrun
 */
public class HttpGetRequest extends HttpRequest {

    public HttpGetRequest(Requester requester, Listener<String> listener, ErrorListener errorListener) {

        super(Request.Method.GET, builderUrl(requester.getUrl(), requester.getMapBody()), listener, errorListener);
    }

    private static String builderUrl(String url, Map<String, String> params) {

        if(params != null && params.size() > 0) {
            url += "?" + AndroidUtils.encodeParameters(params, "UTF-8");
        }
        KLog.i("build url:" + url);
        return url;
    }
}
